<template>
  <h1 ref="target">哈哈哈</h1>
  <button @click="flag = !flag">点击切换图片</button><br>
  <transition>
    <img v-if="flag" src="../../assets/images/qrcode.jpg" alt="">
  </transition>
</template>
<script setup lang="ts">
import { ref } from 'vue'
import { useIntersectionObserver } from '@vueuse/core'
const target = ref(null)
const flag = ref(true)

useIntersectionObserver(target,([{ isIntersecting }]) => {
  console.log(isIntersecting)
  
})
</script>

<style scoped lang="less">
.v-leave-from{
opacity: 1;
}
.v-leave-active{
  transition: all .5s;
}
.v-leave-to{
opacity: 0;
  
}
</style>``